// function getPagination(json)
// {
//     var pages = [];
//     pages.push({page : 0, title : '首页'});
//     if (json.first && json.last)
//     {
//         pages.push({page : 0, title : '上一页'});
//         pages.push({page : 0, title : '下一页'});
//     }
//     else if (json.first)
//     {
//         pages.push({page : 0, title : '上一页'});
//         pages.push({page : 1, title : '下一页'});
//     }
//     else if (json.last)
//     {
//         pages.push({page : json.totalPages - 2 < 0 ? 0 : json.totalPages - 2, title : '上一页'});
//         pages.push({page : json.totalPages - 1 < 0 ? 0 : json.totalPages - 1, title : '下一页'});
//     }
//     else
//     {
//         pages.push({page : json.number - 1 < 0 ? 0 : json.number - 1, title : '上一页'});
//         pages.push({page : json.number + 1, title : '下一页'});
//     }
//     pages.push({page : json.totalPages - 1, title : '尾页'});
//
//     var pagination = {};
//     pagination.pages = pages;
//     pagination.totalPages = json.totalPages;
//     pagination.number = json.number;
//     pagination.totalElements = json.totalElements;
//
//     return pagination;
// }
// function pagingScope($scope, sortByMap)
// {
//     $scope.page = 0;
//     $scope.size = 10;
//     $scope.sort = "";
//     $scope.sortAscOrDesc = false;
//     $scope.sortByMap = sortByMap;
//
//     $scope.sortBy = function(sortStr)
//     {
//         sortStr = sortStr.replace("\.", "_");
//         $scope.sort = sortStr;
//         $scope.sortByMap[sortStr] = !$scope.sortByMap[sortStr];
//         $scope.sortAscOrDesc = $scope.sortByMap[sortStr];
//         $scope.loadItems();
//
//         for (var i in $scope.sortByMap)
//         {
//             $("#id_sort_icon_" + i).attr("class", "fa fa-fw fa-sort");
//             if (i == sortStr)
//             {
//                 $("#id_sort_icon_" + sortStr).attr("class", ($scope.sortAscOrDesc ? "fa fa-fw fa-sort-asc" : "fa fa-fw fa-sort-desc"));
//             }
//         }
//     }
//
// }
/*<![CDATA[*/


function getPagination(json)
{
    var pages = [];

    pages.push({page : 0, title : top_page});
    if (json.first && json.last)
    {
        pages.push({page : 0, title :previous_page});
        pages.push({page : 0, title : next_page});
    }
    else if (json.first)
    {
        pages.push({page : 0, title : previous_page});
        pages.push({page : 1, title : next_page});
    }
    else if (json.last)
    {
        pages.push({page : json.totalPages - 2 < 0 ? 0 : json.totalPages - 2, title : previous_page});
        pages.push({page : json.totalPages - 1 < 0 ? 0 : json.totalPages - 1, title : next_page});
    }
    else
    {
        pages.push({page : json.number - 1 < 0 ? 0 : json.number - 1, title : previous_page});
        pages.push({page : json.number + 1, title : next_page});
    }
    pages.push({page : json.totalPages - 1, title : tail_page});

    var pagination = {};
    pagination.pages = pages;
    pagination.totalPages = json.totalPages;
    pagination.number = json.number;
    pagination.totalElements = json.totalElements;

    return pagination;
}
function pagingScope($scope, sortByMap)
{
    $scope.page = 0;
    $scope.size = 10;
    $scope.sort = "";
    $scope.sortAscOrDesc = false;
    $scope.sortByMap = sortByMap;
    $scope.sortBy = function(sortStr)
    {
        sortStr = sortStr.replace("\.", "_");
        $scope.sort = sortStr;
        $scope.sortByMap[sortStr] = !$scope.sortByMap[sortStr];
        $scope.sortAscOrDesc = $scope.sortByMap[sortStr];
        $scope.loadItems();

        for (var i in $scope.sortByMap)
        {
            $("#id_sort_icon_" + i).attr("class", "fa fa-fw fa-sort");
            if (i == sortStr)
            {
                $("#id_sort_icon_" + sortStr).attr("class", ($scope.sortAscOrDesc ? "fa fa-fw fa-sort-asc" : "fa fa-fw fa-sort-desc"));
            }
        }
    }

}
//自定义日期格式
Date.prototype.format = function(format) {
    var date = {
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "h+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "q+": Math.floor((this.getMonth() + 3) / 3),
        "S+": this.getMilliseconds()
    };
    if (/(y+)/i.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
    }
    for (var k in date) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
        }
    }
    return format;
}
/*]]>*/